{# plantilla para formularios #}

{# INPUT #}
{% macro  input(type, class, id, name, value, disabled) %}
<input type="{{type|default('text')}}" class="{{class}}" value="{{ value }}" name="{{ name }}" id="{{ id|default(name) }}" {{ disabled ? 'disabled="true"':' ' }}/>
{% endmacro%}

{# SELECT#}
{% macro select(class, id, name, disabled, values, selected) %}
<select class="{{class}}" id="{{id|default(name)}}" name="{{name}}" >
    {% for elemento in values %}
        <option value="{{ elemento.id}}" {{ selected == elemento.id?"selected='selected'":""}}>{{ elemento.nombre }}</option>
    {% endfor %}
</select>
{% endmacro%}

{# CONTROL - INPUT#}
{% macro control_input(type, class, id, name, value, disabled)%}
<div class="control-group">
    <label for="{{ name }}">{{ name|title }}</label>
    <div class="controls">
        {{ form.input(type, class, id, name, value, disabled) }}
    </div>
</div>
{% endmacro %}

{# CONTROL - SELECT#}
{% macro control_select(class, id, name, disabled, values, selected)%}
<div class="control-group">
    <label for="{{ name }}">{{ name|title }}</label>
    <div class="controls">
        {{ form.select(class, id, name, disabled, values, selected) }}
    </div>
</div>
{% endmacro %}
